const fs = require('fs');
const path = require('path');
const Jimp = require('jimp');

const types = ['INTJ','INTP','ENTJ','ENTP','INFJ','INFP','ENFJ','ENFP','ISTJ','ISFJ','ESTJ','ESFJ','ISTP','ISFP','ESTP','ESFP'];
const outDir = path.join(__dirname, '..', 'MyPro', 'static', 'icons', 'mbti');
const size = 256;
const bg = '#6B5B95'; // 品牌主色

(async () => {
  if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
  const font = await Jimp.loadFont(Jimp.FONT_SANS_64_WHITE);
  for (const t of types) {
    const img = new Jimp(size, size, bg);
    const text = t;
    const w = Jimp.measureText(font, text);
    const h = Jimp.measureTextHeight(font, text, size);
    img.print(font, (size - w) / 2, (size - h) / 2, text);
    const file = path.join(outDir, `${t.toLowerCase()}.png`);
    await img.writeAsync(file);
    console.log('Generated', file);
  }
})(); 